package com.yida.gwj.api.factory;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import com.yida.common.core.domain.R;
import com.yida.common.core.exception.ServiceException;
import com.yida.common.core.web.page.TableDataInfo;
import com.yida.gwj.api.domain.GwjFinanceAccountDetail;
import com.yida.gwj.api.domain.GwjFinanceAccountMain;
import com.yida.gwj.api.domain.GwjFinanceBank;
import com.yida.gwj.api.domain.GwjFinanceMoney;
import com.yida.gwj.api.domain.request.RemoteAccountDetailForRateRequest;
import com.yida.gwj.api.domain.request.RemoteGwjFinanceAccountDetailRequest;
import com.yida.gwj.api.domain.request.RemoteGwjFinanceAccountMainRequest;
import com.yida.gwj.api.service.RemoteGwjFinanceService;

/**
 * 公维金服务降级处理
 *
 * @author hmh
 */
@Component
public class RemoteGwjFinanceFallbackFactory implements FallbackFactory<RemoteGwjFinanceService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteGwjFinanceFallbackFactory.class);

    @Override
    public RemoteGwjFinanceService create(Throwable throwable) {
        log.error("公维金财务服务调用失败:{}", throwable.getMessage());
        return new RemoteGwjFinanceService() {
            @Override
            public R<Integer> addGwjFinanceAccountDetail(GwjFinanceAccountDetail gwjFinanceAccountDetail, String source) {
                return R.fail("新增银行分类帐信息:{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> addBatchGwjFinanceAccountDetail(ArrayList<GwjFinanceAccountDetail> accountDetails, String source) {
                return R.fail("批量新增银行分类帐信息:{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> updateGwjFinanceAccountDetail(GwjFinanceAccountDetail gwjFinanceAccountDetail, String source) {
                return R.fail("修改银行分类帐信息:{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> deleteGwjFinanceAccountDetailByBizId(Long bizId, String source) {
                return R.fail("根据业务ID删除分类帐信息:{}" + throwable.getMessage());
            }

            @Override
            public R<List<GwjFinanceAccountDetail>> selectGwjFinanceAccountDetailListByBizId(Long bizId, String source) {
                return R.fail("根据业务ID查询分类帐信息:{}" + throwable.getMessage());
            }

            @Override
            public R<List<GwjFinanceAccountDetail>> selectGwjFinanceAccountDetailList(GwjFinanceAccountDetail gwjFinanceAccountDetail, String source) {
                return R.fail("查询总账流水（连表 总账流水）:{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> insertGwjFinanceAccountMain(GwjFinanceAccountMain gwjFinanceAccountMain, String source) {
                return R.fail("新增银行总账流水:{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> updateGwjFinanceAccountMain(GwjFinanceAccountMain gwjFinanceAccountMain, String source) {
                return R.fail("修改银行总账流水:{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> deleteGwjFinanceAccountMainByBizId(Long bizId, String source) {
                return R.fail("根据业务ID删除总账流水:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjFinanceAccountMain> selectGwjFinanceAccountMainByBizId(Long bizId, String source) {
                return R.fail("根据业务ID查询总账流水:{}" + throwable.getMessage());
            }

            @Override
            public R<List<GwjFinanceAccountMain>> selectGwjFinanceAccountMainList(GwjFinanceAccountMain gwjFinanceAccountMain, String source) {
                return R.fail("查询总账流水列表:{}" + throwable.getMessage());
            }

            @Override
            public R<TableDataInfo> selectGwjFinanceAccountMainPage(RemoteGwjFinanceAccountMainRequest gwjFinanceAccountMainRequest, String source) {
                return R.fail("查询总账流水列表分页:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjFinanceBank> selectFinanceBankByBankIdAndAreaId(Long bankId, Long areaId, String source) {
                return R.fail("通过银行ID和地区ID查询银行信息详细信息:{}" + throwable.getMessage());
            }

            @Override
            public R<GwjFinanceMoney> selectFinanceMoneyByMoneyId(Long moneyId, String source) {
                return R.fail("获取缴存金额收入总帐明细详细信息:{}" + throwable.getMessage());
            }

            @Override
            public R<List<GwjFinanceMoney>> selectFinanceMoneyList(GwjFinanceMoney financeMoney, String source) {
                return R.fail("查询缴存金额收入总帐明细列表:{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> updateFinanceMoney(GwjFinanceMoney financeMoney, String source) {
                return R.fail("修改缴存金额收入总帐明细:{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> updateBatchGwjFinanceAccountDetail(ArrayList<GwjFinanceAccountDetail> details, String source) {
                return R.fail("修改分账流水业务信息：{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> clearFinanceMoneyBizInfo(GwjFinanceMoney financeMoney, String source) {
                return R.fail("缴存金额收入总帐明细清空绑定的业务信息:{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> insertBatchGwjFinanceAccountDetailInner(ArrayList<GwjFinanceAccountDetail> accountDetailArrayList, String source) {
                return R.fail("保存分账流水业务信息：{}" + throwable.getMessage());
            }

            @Override
            public R<List<GwjFinanceAccountDetail>> getGwjFinanceAccountDetailList(RemoteGwjFinanceAccountDetailRequest detailRequest, String source) {
                return R.fail("查询分账列表：{}" + throwable.getMessage());
            }

            @Override
            public R<TableDataInfo> getGwjFinanceAccountDetailPage(RemoteGwjFinanceAccountDetailRequest detailRequest, String source) {
                return R.fail("查询分账列表分页：{}" + throwable.getMessage());
            }

            @Override
            public R<List<GwjFinanceAccountDetail>> getListForRate(RemoteAccountDetailForRateRequest request, String source) {
                throw new ServiceException("查询分账列表失败");
            }

            @Override
            public R<GwjFinanceAccountMain> getGwjFinanceAccountMain(GwjFinanceAccountMain financeAccountMain, String source) {
                return R.fail("查询总账流水异常：{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> deleteGwjFinanceAccountMain(GwjFinanceAccountMain financeAccountMain, String source) {
                return R.fail("删除总账流水异常：{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> deleteGwjFinanceAccountDetail(GwjFinanceAccountDetail financeAccountDetail, String source) {
                return R.fail("删除分类账流水异常：{}" + throwable.getMessage());
            }

            @Override
            public R<Map<Long, String>> selectFinanceBankMapInner(Long areaId, String source) {
                return R.fail("查询银行Map异常：{}" + throwable.getMessage());
            }

            @Override
            public R<Map<String, BigDecimal>> selectGwjFinanceAccountDetailStatistics(GwjFinanceAccountDetail financeAccountDetail, String source) {
                return R.fail("获取分类账统计信息异常：{}" + throwable.getMessage());
            }

            @Override
            public R<Integer> updateGwjFinanceAccountMainInfo(GwjFinanceAccountMain gwjFinanceAccountMain, String source) {
                return R.fail("修改总账流水是吧：{}" + throwable.getMessage());
            }
        };
    }

}
